package com.framework.common.Enums;

public enum RoleTypeEnum {
	
	DEFAULT("默认角色", "ROLE_USER", 0),
	GUIDE("领队", "ROLE_GUIDE", 1),
	ORGANIZATION("机构", "ROLE_ORG", 2),
	CITY_PRO("城市代理", "ROLE_CITY_PRO", 3),
	ADMIN("系统管理员", "ROLE_ADMIN", 4),
	TOURIST("游客", "ROLE_TOURIST", 5);
	
    private final String name;
    
    private final String code;

    private final Integer value;

    private RoleTypeEnum(String name, String code, Integer value) {
        this.name = name;
        this.code = code;
        this.value = value;
    }

    public String getName() {
        return name;
    }

    public String getCode() {
		return code;
	}

	public Integer getValue() {
        return value;
    }
	
	public static Integer getValue(String code) {
		RoleTypeEnum[] values = RoleTypeEnum.values();
    	for (RoleTypeEnum e : values) {
    		if (e.getCode().equals(code)) {
    			return e.getValue();
    		}
    	}
    	return null;
	}
	
	public static String getCode(Integer value) {
    	for (RoleTypeEnum e : RoleTypeEnum.values()) {
    		if (e.getValue().equals(value)) {
    			return e.getCode();
    		}
    	}
    	return null;
	}
	
	public static String getName(Integer value) {
    	for (RoleTypeEnum e : RoleTypeEnum.values()) {
    		if (e.getValue().equals(value)) {
    			return e.getName();
    		}
    	}
    	return null;
	}


}
